//
//  CommodityTitleView.swift
//  iPhone
//
//  Created by Toj on 8/9/22.
//

import UIKit

class CommodityTitleView: UICollectionReusableView {
    
    var isImage = true {
        didSet {
            imageView.isHidden = !isImage
        }
    }
    
    private lazy var imageView: UIImageView = {
       let view = UIImageView()
        view.image = "commodity_title_icon".to_image
        return view
    }()
    
    private lazy var titleLable: UILabel = {
        let view = UILabel()
        view.text = "SPORT VIP (Video Only)"
        view.textColor = UIColor(hex: "#333333")
        view.font = UIFont.boldSystemFont(ofSize: 16)
         return view
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        addSubview(imageView)
        addSubview(titleLable)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        imageView.snp.makeConstraints { make in
            make.left.equalTo(17)
            make.width.equalTo(14)
            make.height.equalTo(24)
            make.centerY.equalTo(self)
        }
        
        var left = isImage ? 36 : 16
        titleLable.snp.makeConstraints { make in
            make.left.equalTo(left)
            make.centerY.equalTo(imageView)
        }
    }
    
    deinit {
        // print("-->toj: CommodityHeaderView: deinit")
    }
}
